package com.chenliwu.demo.base;

/**
 * @author chenlw 2021-12-14
 * @since 1.0.0
 */
public class DataTypeTest {

    public static void main(String[] args) {
        // test2();
        test3();
    }

    static void test2() {
        // 整数比较
        int a = 1000;
        int b = 1000;
        // true
        System.out.println(a == b);

        //  Integer c = Integer.valueOf(1000)
        Integer c = 1000;
        Integer d = 1000;
        // false,必须用equals()进行对象比较
        System.out.println(c == d);

        Integer e = 100;
        Integer f = 100;
        // true, [-128,127]区间是取缓存
        System.out.println(e == f);
    }

    static void test3() {
        // 字符串比较
        String s = "123456";
        String s1 = "123456";
        String s2 = "123" + "456";
        String s3 = "456";
        String s4 = "123" + s3;

        System.out.println(s == s1);// true
        System.out.println(s == s2);// true
        System.out.println(s == s4);// false
    }

    static void test1() {
        long l1 = 10;
        int i1 = 10;

        float f1 = 10;
        float f2 = 10.2F;

        double d1 = 10;
        double d2 = 10.2;

        char ch1 = 48;
        System.out.println(ch1);
    }

}
